#include <math.h>
#include <stdio.h>

#define PI 3.1415926535897932384626434
#define RADIANS_PER_DEGREE (PI / 180.0)
#define DEGREES_PER_RADIAN (180.0 / PI)

int main(void) {
    double theta;
    double sin_theta = 0.0, cos_theta = 1.0, sin_last_theta = 0.0, cos_last_theta = 1.0;
    // precompute sine and cosine of the increment
    double sin_increment = sin(1.0 * RADIANS_PER_DEGREE);
    double cos_increment = cos(1.0 * RADIANS_PER_DEGREE);
    // circle
    for (theta = 0; theta < 360.0 * RADIANS_PER_DEGREE; theta += 1.0 * RADIANS_PER_DEGREE) {
        // compute sin(theta)
        if (theta == 0.0) {
            sin_last_theta = 0.0;
            cos_last_theta = 1.0;
            sin_theta = 0.0;
            cos_theta = 1.0;
        } else {
            sin_last_theta = sin_theta;
            cos_last_theta = cos_theta;
            sin_theta = sin_increment * cos_last_theta + cos_increment * sin_last_theta;
            cos_theta = cos_increment * cos_last_theta - sin_increment * sin_last_theta;
        }
        printf("%6.2f %6.4f %6.4f\n", theta * DEGREES_PER_RADIAN, sin(theta), sin_theta);
    }
    return 0;
}
